<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body></body>
    <script type="module">
        import loader from "https://cdn.jsdelivr.net/npm/@assemblyscript/loader";
        fetch("./build/optimized.wasm")
            .then((res) => res.arrayBuffer())
            .then((buffer) => {
                loader.instantiate(buffer).then(({ exports }) => {
                    const {
                        blendColors,
                        __pin,
                        __getArray,
                        Uint16Array_ID,
                        __newArray,
                    } = exports;
                    const input = [
                        [0, 0, 0, 0, 0, 0, 0],
                        [0, 10, 0x123456, 0, 0x487342, 0, 1],
                    ].flat();
                    let arrayPtr = __pin(
                        __newArray(exports.Uint16Array_ID, input)
                    );
                    const data = blendColors(arrayPtr);
                    console.log(__getArray(data));
                });
            });
    </script>
</html>
